from django.shortcuts import render

# Create your views here.
from django.contrib.auth import get_user_model
from rest_framework import serializers, viewsets
from rest_framework.permissions import IsAdminUser

User = get_user_model()


# 定义序列化数据 把user表里面的 url username mail is_staff字段提取出来
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        # 使用哪个数据模型
        model = User
        # 序列化哪些字段出来
        fields = ('url', 'password', 'is_staff')


class UserViewSet(viewsets.ModelViewSet):
    """
    阿斯蒂芬
    """
    queryset = User.objects.all()
    serializer_class = UserSerializer

    def get_queryset(self):
        return User.objects.all()
